﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Apq.JinDu
{
	/// <summary>
	/// 表示进度的class,delegate,用于进度事件等
	/// </summary>
	public class JinDu
	{
		/// <summary>
		/// 命名,用于标识是什么的进度
		/// </summary>
		[DefaultValue("")]
		public string Name { get; set; }
		/// <summary>
		/// 分块编号
		/// </summary>
		[DefaultValue(0)]
		public int SubNo { get; set; }
		/// <summary>
		/// 总量
		/// </summary>
		[DefaultValue(100)]
		public long Total { get; set; }

		private long _Current = 0;
		/// <summary>
		/// 当前
		/// </summary>
		[DefaultValue(0)]
		public long Current
		{
			get { return _Current; }
			set
			{
				_Current = value;
				if (value > Total)
				{
					_Current = Total;
				}
			}
		}

		/// <summary>
		/// 用于存放用户需要的对象
		/// </summary>
		public object Tag { get; set; }

		/// <summary>
		/// 构造函数
		/// </summary>
		public JinDu(long Total, long Current = 0, int SubNo = 0, string Name = "")
		{
			this.Total = Total;
			this.Current = Current;
			this.SubNo = SubNo;
			this.Name = Name ?? string.Empty;
		}
	}

	/// <summary>
	/// 进度改变
	/// </summary>
	public delegate void JinDuChangedHandler(object sender, JinDu e);
}
